<html>
<head>
<title>Fact Get Test</title>
<link rel="stylesheet" type="text/css" href="wick.css" />
<script type="text/javascript" language="JavaScript" src="jquery.js"></script>
<script>
$(document).ready(function(){
  $.ajax({
    type: "GET",
    url: "http://localhost:8080/all/country",
    dataType: "json",
    success: onLoadAllCountry
  });
  $.ajax({
    type: "GET",
    url: "http://localhost:8080/all/club",
    dataType: "json",
    success: onLoadAllClub
  });
  $.ajax({
    type: "GET",
    url: "http://localhost:8080/all/player",
    dataType: "json",
    success: onLoadAllPlayer
  });
  $.ajax({
    type: "GET",
    url: "http://localhost:8080/all/user",
    dataType: "json",
    success: onLoadAllUser
  });
  
  //TODO delete
  $("form#fact-get-form").submit(function(){

  return false;
  });
  
});

function onLoadAllCountry(data, textStatus) {
  window.all_country_full = data;
  window.all_country_coll = [];
  $.each(data, function(i,val){all_country_coll[i]=val.country_name;});
}

function onLoadAllUser(data, textStatus) {
  window.all_user_full = data;
  window.all_user_coll = [];
  $.each(data, function(i,val){
    all_user_coll[i]=val.userid;
    $("#userid").append("<option value=\""+val.userid+"\">"+val.userid+"</option>");
  });
}

function onLoadAllClub(data, textStatus) {
  window.all_club_full = data;
  window.all_club_coll = [];
  $.each(data, function(i,val){all_club_coll[i]=val.name;$("#fact-tag").append("<option value=\""+val.key+"\">"+val.name+"</option>");});
}

function onLoadAllPlayer(data, textStatus) {
  window.all_player_full = data;
  window.all_player_coll = [];
  $.each(data, function(i,val){all_player_coll[i]=val.name;$("#fact-tags").append("<option value=\""+val.key+"\">"+val.name+"</option>");});
}

function onFactGet(data, textStatus) {
  //TODO make better
  $("#fact-container").append(data);
}


</script>
</head>
<body>
<form id="fact-get-form" action="http://localhost:8080/fact/getty" method="POST">
<div> 
Get Facts: 
User=<select id="userid" name="userid"/></select>
Querytype=<select id="fact-query" name="fact-query"/><option value="latest">Latest</option><option value="most-liked">Most Liked</option><option value="most-disliked">Most Disiked</option><option value="user-added">Added by you</option><option value="friend-added">Added by friends</option><option value="user-liked">Liked by you</option><option value="user-disliked">Disliked by you</option></select>
Tag=<select id="fact-tags" name="fact-tags" multiple="multiple"/><option value="">None</option></select>
Page=<select id="fact-page" name="fact-page"/><option value="1">01</option><option value="2">02</option><option value="3">03</option><option value="4">04</option><option value="5">05</option></select>
<input id="fact-get-submit" name="fact-get-submit" type="submit" value="Go">
</div>
</from>
<div id="fact-container" style="margin:40px 20px;border:2px solid #ddd;padding:10px"></div>
<script type="text/javascript" language="JavaScript" src="wick.js"></script>
</body>
</html>

